import Cookies from 'js-cookie'

const TokenKey = 'HMHR72'

// 本地保存token
export function getToken () {
  return Cookies.get(TokenKey)
}

export function setToken (token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken () {
  return Cookies.remove(TokenKey)
}

// 保存token的同事保存获取token时的时间戳（判断token有无时效，主动处理token过期）
const timestape = 'HMHR72-TimeStape'

export function getTimeStape () {
  return Cookies.get(timestape)
}

export function setTimeStape () {
  // 设置时间戳，cookie与localstorage本地保存语法一致！
  return Cookies.set(timestape, Date.now())
}

export function removeTimeStape () {
  return Cookies.remove(timestape)
}
